// 会员财务流水
module.exports = (app) => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const AccountSchema = new Schema({    
    wxfId: { type: Schema.Types.ObjectId, ref: "wxfriend" },    
    ownerWxid: { type: String, required: true, index: true }, // 所属微信号
    wxid: { type: String, required: true, index: true }, // wxid
    nick: { type: String }, // 昵称
    amount: { type: Number, default: 0 }, // 充值金额
    remark: { type: String }, // 备注
  }, {
    timestamps: { createdAt: 'createTime', updatedAt: 'updateTime' },
  });

  AccountSchema.index({ createdAt: -1 });
  AccountSchema.index({ ownerWxid: 1 });
  AccountSchema.index({ wxid: 1 });
  
  return mongoose.model("Account", AccountSchema, 'account');
};
